﻿cmake_minimum_required(VERSION 3.16)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(MusicPlayer VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt6 6.2 REQUIRED COMPONENTS Quick)
 find_package(Qt6 COMPONENTS QuickControls2 REQUIRED)

qt_add_executable(appMusicPlayer
    src/main.cpp
)

#set(QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/qml)
#file(GLOB_RECURSE  QML_FILES CONFIGURE_DEPENDS
#    ${QML_DIR}/*.qml)

file(GLOB_RECURSE QML_FILES
     RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
     CONFIGURE_DEPENDS
     src/qml/*.qml
)

message("qml DIR :"${QML_DIR})
foreach(_Var ${QML_FILES})
    message("QML_FILE is " ${_Var})
endforeach()


qt_add_qml_module(appMusicPlayer
    URI MusicPlayer
    VERSION 1.0
    QML_FILES
        ${QML_FILES}

)

target_sources(appMusicPlayer PRIVATE src/resources/res.qrc)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appMusicPlayer PROPERTIES

    # MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appMusicPlayer
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_link_libraries(appMusicPlayer
    PRIVATE Qt6::Quick
)
target_link_libraries(appMusicPlayer
    PRIVATE Qt6::QuickControls2)

include(GNUInstallDirs)
install(TARGETS appMusicPlayer
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
